
<?php
	
	/*include_once('init.php');*/

		$id=$_GET['id'];


        if (!empty($_SERVER['HTTP_X_REQUESTED_WITH'])) {

	        $sql="select * from `cate`  where `pid`='$id'";
			$ruselt=mysqli_query($GLOBALS['link'],$sql);	
			echo ($ruselt->num_rows>0)?1:0;die;

        }

        $row=catedie($id);
    	if ($row>0) {
        	echo '<script>alert("删除成功");location.href="index.php?c=cate&a=news&admin=1";</script>';

        }else{
        	echo '<script>alert("删除失败");history.go(-1);</script>';die;
        };
     
    			
	
	function catedie($pid=0){
			
		$sql="select * from `cate` where `pid`=$pid";
		$row = mysqli_query($GLOBALS['link'],$sql);
		if ($row->num_rows>0) {
			
		
        	while ($arr=mysqli_fetch_assoc($row)) {
        		
	        
	        	catedie($arr['id']);
			}

		}
		
		$row= dei('cate',$pid);

		/*	$sql="delete from `cate`  where `id`='$pid'";
			mysqli_query($GLOBALS['link'],$sql);*/
/*				
	print_r(
	mysqli_affected_rows($GLOBALS['link']));die;*/
	


			return  $row/*mysqli_affected_rows($GLOBALS['link'])*/;
	     };
	     
	     if (!empty($_SERVER['HTTP_X_REQUESTED_WITH'])) {

	      	
			echo json_encode($row);die;

        }








/*        if ($row>0) {
        	echo '<script>alert("删除成功");location.href="index.php?c=news&a=news&admin=1";</script>';

        }else{
        	echo '<script>alert("删除失败");history.go(-1);</script>';die;
        }
    
		


		$sql = "select * from `news` where `id`=$id";
		$row = mysqli_query($link,$sql);
		$arr=mysqli_fetch_assoc($row);
   
  include( VIEW_PATH.$admin.'layst.html');*/


?>
